3eb781fd8oRfPgH7qTh7xvgmwD6NgA tools/internal/xi_start.c
3eb781fd0Eo9K1jEFCSAVzO51i_ngg tools/internal/xi_stop.c
3f108ae2to5nHRRXfvUK7oxgjcW_yA tools/internal/xi_usage.c
+3fb01fd5CGkDlZddcIlPxLwrquLqKA tools/internal/xi_vbd_add.c
+3fb01fd5MoGCWdylPicf4UinUjYfDg tools/internal/xi_vbd_create.c
+3fb01fd54I4P44vZDb1CtDt1BytDtA tools/internal/xi_vbd_info.c
+3fb01fd5B-UeibZkmSCOUZckNyNFYA tools/internal/xi_vbd_list.c
3f86be322bd0h9jG3krZFOUgCDoxZg tools/internal/xi_vif_params.c
3eb781fd7211MZsLxJSiuy7W4KnJXg tools/internal/xi_vifinit
3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
--- /dev/null
+
+#define _GNU_SOURCE
+#include "dom0_defs.h"
+
+/*
+** Add an extent to a VBD; the VBD must have been created previously.
+*/
+int main(int argc, char *argv[])
+{
+ block_io_op_t op;
+ unsigned int domain;
+ unsigned short vdevice, device;
+ int ret;
+
+ if ( argc != 6 )
+ {
+ fprintf(stderr, "Usage: xi_vbd_add <domain> <vdevice> <device>"
+ "<start sector> <nr_sectors>\n");
+ return 1;
+ }
+
+
+ domain = atoi(argv[1]);
+ device = atoi(argv[2]);
+ vdevice = atoi(argv[3]);
+
+ op.cmd = BLOCK_IO_OP_VBD_ADD;
+ op.u.add_params.domain = domain;
+ op.u.add_params.vdevice = vdevice;
+
+ op.u.add_params.extent.device = device;
+ op.u.add_params.extent.start_sector = atol(argv[4]);
+ op.u.add_params.extent.nr_sectors = atol(argv[5]);
+
+ ret = do_block_io_op(&op);
+
+ if(ret < 0) {
+ fprintf(stderr, "error %d attempting to add extent to VBD %04x\n",
+ ret, atoi(argv[2]));
+ return ret;
+ }
+
+ return 0;
+}
--- /dev/null
+
+#define _GNU_SOURCE
+#include "dom0_defs.h"
+
+/*
+** Create a new VBD for a given domain; the VBD can be read-only or
+** read/write, and will be referred to by the relevant domain as 'vdevice'.
+*/
+int main(int argc, char *argv[])
+{
+ block_io_op_t op;
+ unsigned int domain;
+ unsigned short vdevice;
+ int ret;
+
+ if ( argc != 4 )
+ {
+ fprintf(stderr, "Usage: xi_vbd_create <domain> <vdevice> <r/rw>\n");
+ return 1;
+ }
+
+ domain = atoi(argv[1]);
+ vdevice = atoi(argv[2]);
+
+ op.cmd = BLOCK_IO_OP_VBD_CREATE;
+ op.u.create_params.domain = domain;
+ op.u.create_params.vdevice = vdevice;
+ op.u.create_params.mode = 0;
+ if ( strchr(argv[3], 'r') )
+ op.u.create_params.mode |= VBD_MODE_R;
+ if ( strchr(argv[3], 'w') )
+ op.u.create_params.mode |= VBD_MODE_W;
+
+ ret = do_block_io_op(&op);
+
+ if(ret < 0) {
+ fprintf(stderr, "error %d attempting to create VBD %04x\n", ret,
+ atoi(argv[2]));
+ return ret;
+ }
+
+ return 0;
+}
--- /dev/null
+
+#define _GNU_SOURCE
+#include "dom0_defs.h"
+
+
+int main(int argc, char *argv[])
+{
+// block_io_op_t op;
+
+ // XXX SMH: writeme
+
+ return 0;
+}
--- /dev/null
+
+#define _GNU_SOURCE
+#include "dom0_defs.h"
+
+
+#define MAX_DISKS 32
+#define XDA_SIZE (MAX_DISKS * sizeof(xen_disk_t))
+
+/*
+** List VBDs for oneself or a given domain, or list all VBDs in the system.
+*/
+int main(int argc, char *argv[])
+{
+ block_io_op_t op;
+ unsigned int domain;
+ xen_disk_info_t *xdi;
+ int i, ret;
+
+ if ( argc > 2 ) {
+ fprintf(stderr, "Usage: xi_vbd_list [ <domain> | all ]\n");
+ return 1;
+ }
+
+ /* the default (domain == 0) is to probe for own VBDs */
+ domain = 0;
+
+ if ( argc == 2) {
+ if (!strcmp(argv[1], "all"))
+ domain = VBD_PROBE_ALL;
+ else
+ domain = atoi(argv[1]);
+ }
+
+ /* allocate some space for the result */
+ op.cmd = BLOCK_IO_OP_VBD_PROBE;
+ op.u.probe_params.domain = domain;
+ op.u.probe_params.xdi.max = MAX_DISKS;
+ op.u.probe_params.xdi.disks = malloc(XDA_SIZE);
+ op.u.probe_params.xdi.count = 0;
+
+ xdi = &op.u.probe_params.xdi; // convenience
+
+ if(mlock(xdi->disks, XDA_SIZE) != 0 ) {
+ PERROR("Could not lock memory for Xen hypercall");
+ return -1;
+ }
+
+ ret = do_block_io_op(&op);
+
+ if(ret < 0)
+ fprintf(stderr, "error %d attempting to probe VBDs\n", ret);
+
+ (void)munlock(xdi->disks, XDA_SIZE);
+
+ for(i = 0; i < xdi->count; i++) {
+ fprintf(stderr,
+ "Domain %02d %cBD: [R/%c] device %04x capacity %ldkB\n",
+ xdi->disks[i].domain, XD_VIRTUAL(xdi->disks[i].info) ? 'V' :
+ 'P', XD_READONLY(xdi->disks[i].info) ? 'O' : 'W',
+ xdi->disks[i].device, xdi->disks[i].capacity >> 1);
+ }
+
+
+ return ret;
+}